package main.util;

import java.util.List;

import main.handleException.BizException;

import org.apache.commons.lang3.StringUtils;

/**
 * 判断类工具
 * @author wfy
 *
 */
public class JudgeUtil {

	public static void isBlank(String source,String message) {
		if(StringUtils.isBlank(source)) {
			throw new BizException(message,ResultData.EXCEPTION_CODE); 
		}
	}
	
	public static void isZero(int source,String message) {
		if(source==0) {
			throw new BizException(message,ResultData.EXCEPTION_CODE);
		}
	}
	
	@SuppressWarnings("null")
	public static void isEmpty(List<? extends Object> list,String message) {
		if(list==null && list.size()==0) {
			throw new BizException(message, ResultData.EXCEPTION_CODE);
		}
	}
	
	public static void isNull(Object object ,String message) {
		if(object==null) {
			throw new BizException(message, ResultData.EXCEPTION_CODE);
		}
	}
	
	public static void isEquals(String source, String target, String message) {
		if (!StringUtils.equals(source, target)) {
			throw new BizException(message,ResultData.EXCEPTION_CODE);
		}
	}
	
	public static boolean isNull(Object obj) {
		if(obj==null) {
			return true;
		}
		return false;
	}
}
